// kaf-ai/src/main/java/com/yourpackage/ai/service/factory/AiServiceFactory.java

package com.kaf.ai.service.factory;

import com.kaf.ai.constant.AiProvider;
import com.kaf.ai.service.AiService;
import com.kaf.ai.service.impl.DeepSeekAiServiceImpl;
import com.kaf.ai.service.impl.TongyiAiServiceImpl;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
@RequiredArgsConstructor
public class AiServiceFactory {

    private final DeepSeekAiServiceImpl deepSeekService;
    private final TongyiAiServiceImpl tongyiService;

    private Map<String, AiService> serviceMap = new HashMap<>();

    @PostConstruct
    public void init() {
        serviceMap.put(AiProvider.DEEPSEEK.name(), deepSeekService);
//        serviceMap.put(AiProvider.TONGYI.name(), tongyiService);
    }

    public AiService getAiService(String provider) {
        AiService service = serviceMap.get(provider.toUpperCase());
        if (service == null) {
            throw new IllegalArgumentException("不支持的 AI 供应商: " + provider);
        }
        return service;
    }
}